Skip to content

feat: add generic SQL language support#469

Open
liuxy0551 wants to merge 6 commits into
DTStack:nextfrom
liuxy0551:feat_generic_sql
Open

feat: add generic SQL language support#469
liuxy0551 wants to merge 6 commits into
DTStack:nextfrom
liuxy0551:feat_generic_sql

Conversation

@liuxy0551
Copy link
Copy Markdown
Collaborator

概述

基于 Trino 语法裁剪,新增 GenericSQL 通用 SQL 方言,只保留核心 DML/DDL 语法。

支持的语法

  • DML: SELECT, INSERT, UPDATE, DELETE
  • DDL: CREATE TABLE, ALTER TABLE, DROP TABLE
  • 查询特性: JOIN, 子查询, CTE, UNION/INTERSECT/EXCEPT

移除的语法

视图、索引、存储过程、窗口函数、权限管理、事务控制等厂商扩展语法。

主要变更

  • 新增 src/grammar/generic/GenericSql.g4 语法文件
  • 新增 src/parser/generic/ 解析器实现
  • 新增 test/parser/generic/ 测试用例
  • 更新 README 支持列表
  • 重构各方言 entityCollector,统一接口

相关地址

预览地址:https://liuxy0551.github.io/monaco-sql-languages
monaco-sql-languages PR:DTStack/monaco-sql-languages#217

测试

  • 所有现有方言测试通过
  • GenericSQL 独立测试通过

liuxy0551 added 6 commits May 6, 2026 18:07
- Add INTERSECT and EXCEPT to queryNoWith rule for set operations
- Remove 173 unused KW_* lexer rules for removed features (views, indexes,
  grants, transactions, stored procedures, window functions, triggers, etc.)
- Trim nonReserved list to only keywords actually used in parser rules
- Remove unused UNICODE_STRING and DIGIT_IDENTIFIER lexer rules
- Keyword count reduced from 263 to 90 (close to ~100 target)
- All 197 test suites pass (5627 tests)
- Remove core structural keywords from nonReserved so they cannot be
  used as identifiers: SELECT, FROM, WHERE, CREATE, TABLE, INSERT,
  UPDATE, DELETE, DROP, ALTER, SET, JOIN, GROUP, HAVING, ORDER, ON,
  UNION, INTERSECT, EXCEPT, INTO, NOT, AND, OR, IN, BETWEEN, LIKE,
  IS, EXISTS, CASE, WHEN, THEN, ELSE, END, CAST, AS, DISTINCT,
  PRIMARY, CONSTRAINT, REFERENCES, COLUMN, UNIQUE, CHECK, FOREIGN,
  RENAME, RECURSIVE, WITH, NULL, ESCAPE, NULLIF
- Add DIGIT_IDENTIFIER lexer token for identifiers starting with a
  digit (e.g. 123abc, 1st_column)
- Include DIGIT_IDENTIFIER in identifier rule alternatives
…tion

- Add GenericSqlListener and GenericSqlVisitor exports to src/index.ts
- Add GenericSQLOptions interface with configurable diagnostics flag
- Override validate() to return empty array when diagnostics disabled
- Export GenericSQLOptions type from src/index.ts
- Add exitQuerySpecification for QUERY_RESULT entity tracking
- Add exitSelectItem for column entity collection in SELECT clauses
- Track wildcard columns (ColumnDeclareType.ALL) for * and table.*
- Track expression columns with alias support (ColumnDeclareType.EXPRESSION)
- Stage previously untracked files (errorListener, splitListener, semanticContextCollector)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant